The previous code computing rowStart will fail when there are theads since tHead...
authorPlatonides <platonides@users.mediawiki.org>
Mon, 3 May 2010 20:37:30 +0000 (20:37 +0000)
committerPlatonides <platonides@users.mediawiki.org>
Mon, 3 May 2010 20:37:30 +0000 (20:37 +0000)
However, that code probably worked at some time, so perform a computation to ensure that table.rows isn't getting just the tBody contents.
Please cross browser test.
The last code version of this sortables is on http://yoast.com/articles/sortable-table/ and has changed quite a bit. Joost de Valk suggest
using the jQuery based tablesorter.com.

skins/common/wikibits.js

index 6967b7b..0c16626 100644 (file)
@@ -618,7 +618,15 @@ function ts_resortTable( lnk ) {
        // Work out a type for the column
        // Skip the first row if that's where the headings are
        var rowStart = ( table.tHead && table.tHead.rows.length > 0 ? 0 : 1 );
-
+       var bodyRows = 0;
+       if (rowStart == 0 && table.tBodies) {
+               for (var i=0; i < table.tBodies.length; i++ ) {
+                       bodyRows += table.tBodies[i].rows.length;
+               }
+               if (bodyRows < table.rows.length)
+                       rowStart = 1;
+       }
+       
        var itm = '';
        for ( var i = rowStart; i < table.rows.length; i++ ) {
                if ( table.rows[i].cells.length > column ) {